package com.robusta.cityuate.objects;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

@SuppressWarnings("serial")
public class Country implements Serializable{
	
	
	public static final String NAME = "name";
	public static final String COUNTRY = "country";
	public static final String COUNTRY_ID = "id";
	private static final String COUNTRY_CODE = "code";
	
	
	int id;
	String code;
	String name;
	
	
	public Country(int countryId, String countryCode, String countryName) {
		super();
		this.id = countryId;
		this.code = countryCode;
		this.name = countryName;
	}
	
	public Country() {
		
	}

	public static Country getCountryFromJSON(JSONObject countryJSON){
		String countryName;
		int countryId;
		String countryCode;
		try {
			countryName = countryJSON.getJSONObject(COUNTRY).getString(NAME);
		
			countryId=countryJSON.getJSONObject(COUNTRY).getInt(COUNTRY_ID);
			 countryCode= countryJSON.getJSONObject(COUNTRY).getString(COUNTRY_CODE);
			 return new Country(countryId, countryCode, countryName);
		} catch (JSONException e) {
			
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public String toString() {
		
		return name;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
	
	

}
